﻿using System.Web.Mvc;
using LibraryHub.BusinessLogic;

namespace LibraryHub.Controllers
{
    public class HomeController : OneUserController
    {
        private UsersBl usersBl = new UsersBl();

        #region Login

        public ActionResult Login()
        {
            var users = usersBl.ListUsers();
            return View(users);
        }

        [HttpPost]
        public ActionResult Login(int id)
        {
            var user = usersBl.DebugFindUser(id);
            if (user != null)
            {
                CurrentUser = user;
            }
            return RedirectToAction("Index", "Book");
        }

        #endregion

        #region Logout

        public ActionResult Logout()
        {
            return View();
        }

        [HttpPost, ActionName("Logout")]
        public ActionResult LogoutConfirmed()
        {
            CurrentUser = null;
            return RedirectToAction("Index", "Book");
        }

        #endregion

    }
}
